using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace DefaultNamespace.Skill
{
    public class ComboSystem : MonoBehaviour
    {
        private List<string> skillSequence = new List<string>();
        private Dictionary<string, Skill> comboSkills = new Dictionary<string, Skill>();
        public void RegisterSkillCast(string skillName)
        {
            skillSequence.Add(skillName);
            
            // Check for combos
            CheckCombos();
            
            // Start sequence timeout
            StopAllCoroutines();
            StartCoroutine(ResetSequence());
        }
        private IEnumerator ResetSequence()
        {
            yield return new WaitForSeconds(3f);
            skillSequence.Clear();
        }
        private void CheckCombos()
        {
            string sequenceString = string.Join("-", skillSequence);
            foreach (var combo in comboSkills)
            {
                if (sequenceString.EndsWith(combo.Key))
                {
                    // Execute combo skill
                    combo.Value.Activate(gameObject);
                    skillSequence.Clear();
                    break;
                }
            }
        }
    }
}